<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>设置品牌最低刷卡费率</title>
    <script src="js/lib/jquery-1.11.0.js"></script>
    <link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/lib/loading.css" />
    <script src="js/lib/bootstrap.min.js"></script>
    <script src="js/lib/loading.js"></script>
    <script src="js/lib/vue.min.js"></script>
    <script src="js/lib/vue-resource.js"></script>
    <script src="js/base.js" type="text/javascript" charset="utf-8"></script>
</head>
<style>
    body{
        font-size:12px;
    }
    table,
    th,
    td {
        border: 1px solid grey;
        border-collapse: collapse;
        padding: 5px;
        vertical-align: middle !important;
    }
    table td:nth-child(odd) {
        background-color: #f1f1f1;

    }
    table td:nth-child(even) {

    }
    table tr:nth-child(even) {
        background-color:#ffffff;
    }
</style>
<body id="box">
<div class="">
    <!--加载动画-->
    <!--<div class="wrapper">
        <div id="loader-wrapper">
            <div id="loader"></div>
        </div>
    </div>-->
    <div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
        <table class="table table-hover">
            <tbody>
            <tr>
                <th colspan="12">设置品牌费率：</th>
            </tr>
            <tr>
                <td>选择品牌:</td>
                <td colspan="12">
                    <select name="" id="msg1" type="text" class="form-control" style="width:280px;">
                        
                    </select>
                </td>
            </tr>
            <tr>
                <td>选择现金通道:</td>
                <td colspan="12">
                    <select id="msg2" class="form-control" style="width:280px;">
                       
                    </select>
                </td>

            </tr>
            <tr>
                <td>设置普通用户刷卡费率:</td>
                <td colspan="12">
                    <input id="msg3" class="form-control" type="text" style="width:280px;"/>
                </td>
            </tr>
            <tr>
                <td>设置最低刷卡费率:</td>
                <td colspan="12">
                    <input id="msg4" class="form-control" type="text" style="width:280px;"/>
                </td>
            </tr>
            <tr>
                <td colspan="12">
                    <input id="btn" type="btn" value="新增" class="btn btn-danger"/>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
</div>
</body>
<script>
    $(function(){
        /*获取所有贴牌商名称和val*/
        $.ajax({
            type:"GET",
            url:window.baseUrl+"user/brand/query/all",
            async:true,
            dataType:"json",
            data:{
            },
            success:function(data){               
                console.log(data.result)
                var html = "<option selected='selected' value=''>请选择贴牌</option>";
                var vendorJson = eval(data.result);
                for(var i=0; i<vendorJson.length; i++){
                html += "<option value= '"+vendorJson[i].id+"'>"+vendorJson[i].name+"</option>";
                }
                $("#msg1").html('').append(html);
               
            },
            error:function(data){
                alert('失败')
            }
        });
        /*获取所有通道*/
        $.ajax({
            type:"POST",
            url:window.baseUrl+"user/channel/query/all",
            async:true,
            dataType:"json",
            data:{
            },
            success:function(data){               
                console.log(data.result)
                var html = "<option selected='selected' value=''>请选择通道</option>";
                var vendorJson = eval(data.result);
                for(var i=0; i<vendorJson.length; i++){
                html += "<option value= '"+vendorJson[i].id+"'>"+vendorJson[i].name+'--'+vendorJson[i].channelParams+"</option>";
                }
                $("#msg2").html('').append(html);
               
            },
            error:function(data){
                alert('失败')
            }
        })
        $('#btn').click(function(){
            var msg1 = $('#msg1').val();
            var msg2 = $('#msg2').val();
            var msg3 = $('#msg3').val();
            var msg4 = $('#msg4').val();
            console.log(msg1);
            console.log(msg2);
            console.log(msg3);
            console.log(msg4);
            if(msg1==""|| msg2==""|| msg3==""){
                alert('请确认输入信息')
            }else{
                $.ajax({
                    type:"POST",
                    url:window.baseUrl+"user/brandminrate/add",
                    async:true,
                    dataType:"json",
                    data:{
                        brand_id:msg1,
                        channel_id:msg2,
                        rate:msg3,
                        minrate:msg4
                    },
                    success:function(data){
                        alert('成功')
                        console.log(data)
                    },
                    error:function(data){
                        alert('失败')
                    }
                });
            }
        })
    });
</script>
</html>



